package edu.ynmd.class2.database.action;

import edu.ynmd.class2.database.dao.StudentDao;
import edu.ynmd.class2.database.mode.StudentEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.Timestamp;

@Controller
public class PublicAction {

    @Autowired
    private StudentDao studentDao;

    @GetMapping("testDao")
    @ResponseBody
    public boolean testDao() throws Exception{
        //添加
       //StudentEntity student=new StudentEntity();
       //student.setStunum("201621447101");
       //student.setName("姓名");
        //student.setSex("F");
       //student.setBirthday(new Timestamp(System.currentTimeMillis()));
       //student.setNativeplace("云南玉溪");

       //studentDao.save(student);

        //删除

        //StudentEntity student=new StudentEntity();
        //student.setStunum("20162147149");
       // student.setName("姓名修改");
       // studentDao.delete(student);
        //查询单个
       // StudentEntity student=studentDao.findOne("36859734-3d0d-41f7-b6f5-38a06e5da0c8");
       // student.setSex("M");
      //  student.setBirthday(new Timestamp(System.currentTimeMillis()));
      //  student.setNativeplace("红塔区");
      //  studentDao.save(student);
        //删除

        StudentEntity student=new StudentEntity();
        student.setStudent("36859734-3d0d-41f7-b6f5-38a06e5da0c8");
        studentDao.delete(student);

        return true;
    }




}
